{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Xgbfir simple example\n",
    "This is a small working example of Xgbfir usage from Python code."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "from sklearn.datasets import load_iris, load_boston\n",
    "import xgboost as xgb\n",
    "import xgbfir\n",
    "\n",
    "# loading database\n",
    "boston = load_boston()\n",
    "\n",
    "# doing all the XGBoost magic\n",
    "xgb_rmodel = xgb.XGBRegressor().fit(boston['data'], boston['target'])\n",
    "\n",
    "# saving to file with proper feature names\n",
    "xgbfir.saveXgbFI(xgb_rmodel, feature_names=boston.feature_names, OutputXlsxFile = 'bostonFI.xlsx')\n",
    "\n",
    "\n",
    "# loading database\n",
    "iris = load_iris()\n",
    "\n",
    "# doing all the XGBoost magic\n",
    "xgb_cmodel = xgb.XGBClassifier().fit(iris['data'], iris['target'])\n",
    "\n",
    "# saving to file with proper feature names\n",
    "xgbfir.saveXgbFI(xgb_cmodel, feature_names=iris.feature_names, OutputXlsxFile = 'irisFI.xlsx')\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Check working directory. There will be two new files: **bostonFI.xlsx** and **irisFI.xlsx**."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.4.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
